package com.itheima.config;

import com.itheima.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration//说明这个类是一个配置类
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    //在IOC容器中的bean对象就可以注入进来
    private LoginCheckInterceptor loginCheckInterceptor;
    @Override//注册拦截器的方法
    public void addInterceptors(InterceptorRegistry registry) {
        //需要拦截/**所有方法   不需要拦截login方法
        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
